package com.ypd.shop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ypd.common.core.domain.R;
import com.ypd.shop.domain.vo.EnrollVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ypd.common.annotation.Log;
import com.ypd.common.core.controller.BaseController;
import com.ypd.common.core.domain.AjaxResult;
import com.ypd.common.enums.BusinessType;
import com.ypd.shop.domain.AuctionEnrollment;
import com.ypd.shop.service.IAuctionEnrollmentService;
import com.ypd.common.utils.poi.ExcelUtil;
import com.ypd.common.core.page.TableDataInfo;

/**
 * 拍卖报名记录Controller
 * 
 * @author lin
 * @date 2025-03-02
 */

@RestController
@RequestMapping("/shop/enrollment")
@Api(tags = "拍卖报名记录Controller")
public class AuctionEnrollmentController extends BaseController
{
    @Autowired
    private IAuctionEnrollmentService auctionEnrollmentService;

    /**
     * 查询个人的拍卖报名记录列表
     */
    @ApiOperation("查询拍卖报名记录列表")
    @GetMapping("/myList")
    public TableDataInfo myList(AuctionEnrollment auctionEnrollment)
    {
        startPage();
        List<EnrollVo> list = auctionEnrollmentService.selectAuctionEnrollmentMyList(auctionEnrollment);
        return getDataTable(list);
    }

    /**
     * 查询拍卖报名记录列表
     */
    @ApiOperation("查询拍卖报名记录列表")
    @GetMapping("/list")
    public TableDataInfo list(AuctionEnrollment auctionEnrollment)
    {
        startPage();
        List<AuctionEnrollment> list = auctionEnrollmentService.selectAuctionEnrollmentList(auctionEnrollment);
        return getDataTable(list);
    }

    /**
     * 导出拍卖报名记录列表
     */
    @ApiOperation("导出拍卖报名记录列表")
    @PreAuthorize("@ss.hasPermi('shop:enrollment:export')")
    @Log(title = "拍卖报名记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuctionEnrollment auctionEnrollment)
    {
        List<AuctionEnrollment> list = auctionEnrollmentService.selectAuctionEnrollmentList(auctionEnrollment);
        ExcelUtil<AuctionEnrollment> util = new ExcelUtil<AuctionEnrollment>(AuctionEnrollment.class);
        util.exportExcel(response, list, "拍卖报名记录数据");
    }

    /**
     * 获取拍卖报名记录详细信息
     */
    @ApiOperation("获取拍卖报名记录详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(auctionEnrollmentService.selectAuctionEnrollmentById(id));
    }

    /**
     * 新增拍卖报名记录
     */
    @ApiOperation("新增拍卖报名记录")
    @Log(title = "拍卖报名记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuctionEnrollment auctionEnrollment)
    {
        return toAjax(auctionEnrollmentService.insertAuctionEnrollment(auctionEnrollment));
    }

    /**
     * 修改拍卖报名记录
     */
    @ApiOperation("修改拍卖报名记录")
    @PreAuthorize("@ss.hasPermi('shop:enrollment:edit')")
    @Log(title = "拍卖报名记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuctionEnrollment auctionEnrollment)
    {
        return toAjax(auctionEnrollmentService.updateAuctionEnrollment(auctionEnrollment));
    }

    /**
     * 删除拍卖报名记录
     */
    @ApiOperation("删除拍卖报名记录")
    @PreAuthorize("@ss.hasPermi('shop:enrollment:remove')")
    @Log(title = "拍卖报名记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(auctionEnrollmentService.deleteAuctionEnrollmentByIds(ids));
    }
}
